package com.uliky.shouyiLibrary.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
public class MyRedissonConfig {
    /**
     * 创建redissonclient
     * 声明redis ip
     * @shutdow: 销毁方法
     * @return
     * @throws IOException
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redisson() throws IOException {
        Config config = new Config();
        config.useSingleServer().setAddress("redis://192.168.101.65:6379"); //单节点模式，redis地址
//        config.useClusterServers().addNodeAddress("192.168.101.65:6379"，"192.168.101.64:6379"); //集群模式，redis地址
        return Redisson.create(config);
    }
}
